package Servlet;

import Bean.Page;
import Service.FlightService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张
 * Date: 2025-03-14
 * Time: 11:40
 */
//管理员index界面展示航班数据
@WebServlet("/FlightsServlet")
public class FlightsServlet extends HttpServlet {
    private FlightService flightService = new FlightService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json;charset=utf8");
        int pageNo = Integer.parseInt(req.getParameter("pageNo"));
        int pageSize = 5;
        Page page = flightService.selectFlights(pageNo,pageSize);
        System.out.println(page.toString());
        req.setAttribute("list",page.getList());
        req.setAttribute("box",page);
        req.getRequestDispatcher("admin_index.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
